<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html style='height:100%;'>
<head>
<base href="<%=basePath%>">

<title>装修方案审批</title>
<link rel="stylesheet" href="css/vivo.css">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap.min.css">
<link rel="stylesheet" href="css/common.css">
<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" type="text/css"
	href="static/p_house/house_index.css" />
<link rel="stylesheet" type="text/css"
	href="js/webuploader-0.1.5/webuploader.css" />

<script src="js/jquery-1.11.1.js"></script>
<script src="js/bootstrap2/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script>
<script type="text/javascript"
	src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="js/webuploader-0.1.5/webuploader.js"></script>
<script type="text/javascript" src="js/sharefunction.js"></script>
<script src="js/select2/select2.min.js"></script>
<script type="text/javascript" src="js/form.js"></script>
<!-- 图片放大 -->
<script src="js/postbird-img-glass/postbird-img-glass.js"></script>
<script type="text/javascript">
	$(function() {
		//禁用表单和按钮
		hideButton();
		//初始化图片
		getFiles();
		//悬浮提示
		toolTip();
		//修改字段标记记录变量
		<c:set var="marks" value="原数据"/>
	});
</script>
<body >
<!-- 装修方案 -->
<div>
	<!-- 表单开始 -->
	<form id="decorateSchemeForm" method="post">
		<input type="hidden" id="decorateScheme_articleId" />
		<div class="panel panel-default">
			<div class="panel-body">
				<table cellpadding="10" cellspacing="5" class="mytable">
					<tr>
						<td width="90"><span class="style_btn">申报时间</span></td>
						<td><input  name="declareTime" id="declareTime" readonly="readonly" class="Wdate" 
						onclick="WdatePicker()" value="<fmt:formatDate value="${requestScope.ds.declareTime }" pattern="yyyy-MM-dd" />"/>
						<c:if test="${not empty requestScope.map.declareTime }"><span class="toolTip mark-msg" data-tip="<fmt:formatDate  value="${requestScope.map.declareTime }" type="both" pattern="yyyy-MM-dd" />">
							<c:out value="${marks}"/></span>
						</c:if>
						<c:if test="${requestScope.map.declareTime=='' }"><span class="toolTip mark-msg"data-tip="空">
							<c:out value="${marks}"/></span>
						</c:if>
						</td>
					</tr>
					<tr>
						<td width="90"><span class="style_btn">施工方案</span></td>
						<td><input name="schemeName" value="${requestScope.ds.schemeName}"/>
							<c:if test="${not empty requestScope.map.schemeName }"><span class="toolTip mark-msg"data-tip="${requestScope.map.schemeName }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.schemeName=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						<div id='filePicker_schemeName' style="display: none;margin-left:10px">上传</div>
						</td>
					</tr>
					<!-- 施工方案附件 -->
					<tr>
						<td></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_schemeName'></div> <!-- 上传按钮 -->
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">施工图纸</span></td>
						<td><input name="schemeImg"  value="${requestScope.ds.schemeImg}"/>
							<c:if test="${not empty requestScope.map.schemeImg }"><span class="toolTip mark-msg"data-tip="${requestScope.map.schemeImg }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.schemeImg=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						<div id='filePicker_schemeImg' style="display: none;margin-left:10px">上传</div></td>
					</tr>
					<!-- 施工图纸附件 -->
					<tr>
						<td></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_schemeImg'></div> <!-- 上传按钮 -->
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">材料清单</span></td>
						<td><input name="materials"  value="${requestScope.ds.materials}"/>
							<c:if test="${not empty requestScope.map.materials }"><span class="toolTip mark-msg"data-tip="${requestScope.map.materials }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.materials=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						<div id='filePicker_materials' style="display: none;margin-left:10px;">上传</div></td>
					</tr>
					<!-- 材料清单附件 -->
					<tr>
						<td></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_materials'></div> <!-- 上传按钮 -->
						</td>
					</tr>

					<tr>
						<td><span class="style_btn">工期安排</span></td>
						<td><input   name="staDuration" id="sdate"
							readonly="readonly" class="Wdate"
							onclick="WdatePicker({maxDate:'#F{$dp.$D(\'edate\')}'})" value="<fmt:formatDate value="${requestScope.ds.staDuration }" pattern="yyyy-MM-dd" />"/>
							&nbsp;
							<c:if test="${not empty requestScope.map.staDuration }"><span class="toolTip mark-msg"data-tip="<fmt:formatDate  value="${requestScope.map.staDuration }" type="both" pattern="yyyy-MM-dd" />">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.staDuration=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
							至&nbsp; <input readonly="readonly"  
							name="endDuration" id="edate" class="Wdate"
							onclick="WdatePicker({minDate:'#F{$dp.$D(\'sdate\')}'})" value="<fmt:formatDate value="${requestScope.ds.endDuration }" pattern="yyyy-MM-dd" />"/>
							<c:if test="${not empty requestScope.map.endDuration }"><span class="toolTip mark-msg"data-tip="<fmt:formatDate  value="${requestScope.map.endDuration }" type="both" pattern="yyyy-MM-dd" />">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.endDuration=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">安全承诺</span></td>
						<td><input name="promise"  value="${requestScope.ds.promise}" />
							<c:if test="${not empty requestScope.map.promise }"><span class="toolTip mark-msg"data-tip="${requestScope.map.promise }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.promise=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						<div id='filePicker_promise' style="display: none;margin-left:10px;">上传</div></td>
					</tr>
					<!-- 安全承诺附件 -->
					<tr>
						<td></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_promise'></div> <!-- 上传按钮 -->
						</td>
					</tr>

					<tr style="border-bottom:1px solid gray">
						<td><span class="style_btn">专项申请</span></td>
						<td></td>
					</tr>
					<tr>
						<td width="90" align="center">消防</td>
						<td><input name="declareFirecontrol"  value="${requestScope.ds.declareFirecontrol}" />
							<c:if test="${not empty requestScope.map.declareFirecontrol }"><span class="toolTip mark-msg"data-tip="${requestScope.map.declareFirecontrol }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.declareFirecontrol=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						<div id='filePicker_declareFirecontrol' style="display: none;margin-left:10px;">上传</div></td>
					</tr>
					<!-- 安全承诺附件 -->
					<tr>
						<td></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_declareFirecontrol'></div> <!-- 上传按钮 -->
						</td>
					</tr>

					<tr>
						<td align="center">电力</td>
						<td><input name="declareElectricity" value="${requestScope.ds.declareElectricity}"/>
							<c:if test="${not empty requestScope.map.declareElectricity }"><span class="toolTip mark-msg"data-tip="${requestScope.map.declareElectricity }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.declareElectricity=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						<div id='filePicker_declareElectricity' style="display: none;margin-left:10px;">上传</div></td>
					</tr>
					<!-- 安全承诺附件 -->
					<tr>
						<td></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_declareElectricity'></div> <!-- 上传按钮 -->
						</td>
					</tr>

					<tr>
						<td align="center">燃气</td>
						<td><input name="declareFuelgas" value="${requestScope.ds.declareFuelgas}"  />
							<c:if test="${not empty requestScope.map.declareFuelgas }"><span class="toolTip mark-msg"data-tip="${requestScope.map.declareFuelgas }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.declareFuelgas=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						<div id='filePicker_declareFuelgas' style="display: none;margin-left:10px;">上传</div></td>
					</tr>
					<!-- 安全承诺附件 -->
					<tr>
						<td></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_declareFuelgas'></div> <!-- 上传按钮 -->
						</td>
					</tr>

					<tr>
						<td align="center">其他</td>
						<td><input name="declareOther"  value="${requestScope.ds.declareOther}"  />
							<c:if test="${not empty requestScope.map.declareOther }"><span class="toolTip mark-msg"data-tip="${requestScope.map.declareOther }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.declareOther=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						<div id='filePicker_declareOther' style="display: none;margin-left:10px;">上传</div></td>
					</tr>
					<!-- 安全承诺附件 -->
					<tr>
						<td></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_declareOther'></div> <!-- 上传按钮 -->
						</td>
					</tr>

				</table>
			</div>
			<!-- 专项申报 -->
		</div>
		<input type="hidden" id="entityId_id" name="id" value="${requestScope.ds.id }"/>
		<input type="hidden" id="apId" name="apId" value="${requestScope.apId }"/>
		<c:if test="${requestScope.notPassExamine}">
			<!-- 修改时添加变更说明 -->
			<div style="margin:10px;" id="approvalRemark">
				审批意见<textarea rows="3" name="approvalRemark"style="width:70%"></textarea><span style="color:red;">*</span>
			</div>
			<div style="width:100%;text-align:center; padding-top:0px">
				<button class="btn btn-danger radius my-btn"
					onclick="savaScheme(0)" type="button">同意</button>
				<button class="btn btn-default radius"
					onclick="savaScheme(1)" type="button">拒绝</button>
			</div>
		</c:if>
	</form>
	<!-- 表单结束 -->
</div>
<script type="text/javascript">
	
	function hideButton(){
		//编辑状态下将input装该改为只读
		$("#decorateSchemeForm input").attr("readonly", "readonly");
		$("#decorateSchemeForm .Wdate").attr("disabled", true);
		//禁止点击上传按钮
		$("#decorateSchemeForm div[id^='filePicker_']").css("display","none");
		
	}
	//图片附件信息
	function getFiles(){
		var dSchemeId = $("#decorateSchemeForm").find("#entityId_id").val();
		//展示图片原数据
		getFileListByFlag(dSchemeId, "施工方案",2,"#list_schemeName", setSchemeRFL, imgPlus);
		getFileListByFlag(dSchemeId, "施工图纸",2, "#list_schemeImg", setSchemeRFL, imgPlus);
		getFileListByFlag(dSchemeId, "材料清单",2,"#list_materials", setSchemeRFL, imgPlus);
		getFileListByFlag(dSchemeId, "安全承诺",2, "#list_promise", setSchemeRFL, imgPlus);
		getFileListByFlag(dSchemeId, "消防申请",2, "#list_declareFirecontrol", setSchemeRFL, imgPlus);
		getFileListByFlag(dSchemeId, "电力申请",2, "#list_declareElectricity", setSchemeRFL, imgPlus);
		getFileListByFlag(dSchemeId, "燃气申请",2, "#list_declareFuelgas", setSchemeRFL, imgPlus);
		getFileListByFlag(dSchemeId, "其它申请",2, "#list_declareOther", setSchemeRFL, imgPlus);
		<c:if test="${requestScope.notPassExamine}"> 
		//编辑时提交的临时附件
		var fileCas=${requestScope.caList};
		if(fileCas.length > 0){
			var schemeName = "";//施工方案
			var schemeImg = "";//施工图纸
			var materials = "";//材料清单
			var promise = "";//安全承诺
			var declareFirecontrol = "";//消防申请
			var declareElectricity = "";//电力申请
			var declareFuelgas = "";//燃气申请
			var declareOther = "";//其它申请
			for(var i=0;i<fileCas.length;i++){
				if(fileCas[i].articleId == "施工方案"){
					schemeName += (","+fileCas[i].accessoryCAId);
				}else if(fileCas[i].articleId == "施工图纸"){
					schemeImg += (","+ fileCas[i].accessoryCAId);
				}else if(fileCas[i].articleId == "材料清单"){
					materials += (","+ fileCas[i].accessoryCAId);
				}else if(fileCas[i].articleId == "安全承诺"){
					promise += (","+ fileCas[i].accessoryCAId);
				}else if(fileCas[i].articleId == "消防申请"){
					declareFirecontrol += (","+ fileCas[i].accessoryCAId);
				}else if(fileCas[i].articleId == "电力申请"){
					declareElectricity += (","+ fileCas[i].accessoryCAId);
				}else if(fileCas[i].articleId == "燃气申请"){
					declareFuelgas += (","+ fileCas[i].accessoryCAId);
				}else if(fileCas[i].articleId == "其它申请"){
					declareOther += (","+ fileCas[i].accessoryCAId);
				}
			}
			if(schemeName != ""){
				getFileTempList(schemeName.substring(1),"#list_schemeName", setSchemeRFL, imgPlus);
			}
			if(schemeImg != ""){
				getFileTempList(schemeImg.substring(1), "#list_schemeImg", setSchemeRFL, imgPlus);
			}
			if(materials != ""){
				getFileTempList(materials.substring(1),"#list_materials", setSchemeRFL, imgPlus);
			}
			if(promise != ""){
				getFileTempList(promise.substring(1),"#list_promise", setSchemeRFL, imgPlus);
			}
			if(declareFirecontrol != ""){
				getFileTempList(declareFirecontrol.substring(1),"#list_declareFirecontrol", setSchemeRFL, imgPlus);
			}
			if(declareElectricity != ""){
				getFileTempList(declareElectricity.substring(1),"#list_declareElectricity", setSchemeRFL, imgPlus);
			}
			if(declareFuelgas != ""){
				getFileTempList(declareFuelgas.substring(1),"#list_declareFuelgas", setSchemeRFL, imgPlus);
			}
			if(declareOther != ""){
				getFileTempList(declareOther.substring(1),"#list_declareOther", setSchemeRFL, imgPlus);
			}
		}
		</c:if>
	}
	function savaScheme(opt){
		var url = "customer/dm/disposeScheme";
		var apId = '${requestScope.apId }';
		var exDataId = '${exDataId}';
		var approvalRemark = $("textarea[name='approvalRemark']").val();
		var formData = {
				exDataId:exDataId,
	        	opt:opt,
	        	apId:apId,
	        	approvalRemark:approvalRemark
	    };
		disposeSave(opt,url,formData);
	}
	
	//设置待删除附件的值到集合中
	function setSchemeRFL(id, _this) {
		layer.confirm('删除该图片？', {
			title : '警告',
			icon : 0,
			shade : [ 0.1, '#fff' ]
		}, function() {
			schemeFileList.push(id);
			//删除指定缩略图
			$("#" + id).remove();
			layer.close(layer.index);
		});
	}

	//本页面图片放大通用方法,同时隐藏上传按钮与图片删除按钮
	function imgPlus(data){
		$.each(data,function(i,v){
			hideFileBtn(v.id);
			PostbirdImgGlass.init({
		    	domSelector:"#"+v.id+" img",
		    	animation:true,
		    	//height:'80%',
		    	myDocument:window.parent.parent.parent
			});
		});
	}
	//隐藏附件删除按钮
	function hideFileBtn(id){
		$("#"+id+" span.uploadcancel").hide();
	}

	
	
</script>
</body>
</html>
